//
//  FRQWalletVerificationViewController.m
//  FRQBluetoothKit_Example
//
//  Created by admin on 2023/10/24.
//  Copyright © 2023 xuchunhai. All rights reserved.
//

#import "FRQWalletVerificationViewController.h"
#import "WalletVerificationViews.h"
#import "FRQDownSuccessViewController.h"
#import "FRQWalletVerificationWebViewController.h"
@interface FRQWalletVerificationViewController ()
@property (nonatomic,strong) WalletVerificationViews *WalletVerificationView;
@end

@implementation FRQWalletVerificationViewController
- (WalletVerificationViews *)WalletVerificationView{
    if (nil==_WalletVerificationView) {
        _WalletVerificationView=skXibView(@"WalletVerificationViews");
        [self.view addSubview:_WalletVerificationView];
        [_WalletVerificationView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_topLayoutGuide);
            make.bottom.mas_equalTo(self.mas_bottomLayoutGuide);
            make.right.left.mas_equalTo(0);
        }];
        @weakify(self)
        [[_WalletVerificationView.btnVerify rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            [self walletAdd];
        }];
        [[_WalletVerificationView.btnSelect rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            FRQWalletVerificationWebViewController *view=[[FRQWalletVerificationWebViewController alloc] init];
            view.view.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.7];
            view.modalPresentationStyle = UIModalPresentationOverFullScreen;
            [view setWebBack:^{
                UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
                NSString *string=pasteBoard.string;
                
                _WalletVerificationView.txtCode.text=string;
            }];
            [self presentViewController:view animated:NO completion:^{
                
            }];
        }];
        
    }
    return _WalletVerificationView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"Wallet Verification";
    self.WalletVerificationView.hidden=NO;
}
-(void)walletAdd{
    NSDictionary *dic=@{@"securityCode":self.WalletVerificationView.txtCode.text,
    };
    [skNetTools skPOSTWithURL:[NSString stringWithFormat:@"%@%@",skURL,@"app/user/wallet/add"] parameters:dic cachePolicy:0 callback:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        NSLog(@"数据=%@",responseObject);
        skNetModel *model=responseObject;
        if(model.code==200){
            FRQDownSuccessViewController *view=[[FRQDownSuccessViewController alloc] init];
            [self.navigationController pushViewController:view animated:YES];
        }else{
            [SkToast SkToastShow:model.msg];
        }
        
    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
